<?php
include_once '../inc/config.inc.php';
include_once '../inc/mysqli.inc.php';
include_once '../inc/tool.inc.php';
if(!isset($_GET['id'])||!is_numeric($_GET['id'])||$_GET['id']<1){
    skip('index.php','error','id参数不合法！ ');
}
$link=connect();
$memberid=is_login($link);
$queryf="select *from fatherModule where id={$_GET['id']}";
$resultf=execute($link,$queryf);
if(mysqli_num_rows($resultf)!=1){
    skip('index.php','error','id参数不合法！ ');
}
$dataf=mysqli_fetch_assoc($resultf);
$dataf=dehtml($dataf);


$template='双亲列表页';
include_once 'inc/header.inc.php';
?>


        <div class="lftop">
            <div class="wrap">
                <h2 class="top_dir"><a href="index.php">首页</a>&nbsp;&gt;&nbsp;<a href='<?php echo "parentList.php?id={$dataf['id']}"; ?>'><?php echo $dataf['moduleName']; ?></a></h2>
            </div>
        </div>


        <div class="lfmain">
            <div class="wrap clear-float">
                <div class="lfleft fl">
                    <div class="content">
                        <div class="subt">
                            <h3><?php echo $dataf['moduleName']; ?></h3>
                            <div class="num">
                                <?php  
                                $count_all=0;$count_today=0;
                                $queryc="select *from childModule where referid={$_GET['id']} order by sort desc";
                                $resultc=execute($link,$queryc);
                                while($datac=mysqli_fetch_assoc($resultc)){
                                    $datac=dehtml($datac);
                                    $queryct="select *from content where cmid={$datac['id']}";
                                    $resultct=execute($link,$queryct);
                                    $count_all+=mysqli_num_rows($resultct);
                                    $queryct="select *from content where cmid={$datac['id']} and time>curdate()";
                                    $resultct=execute($link,$queryct);
                                    $count_today+=mysqli_num_rows($resultct);
                                }
                                
                                ?>
                                今日：<span><?php echo $count_today; ?></span>&nbsp;&nbsp;&nbsp;&nbsp;
                                总帖：<span><?php echo $count_all; ?></span>
                            </div>
                            <div class="sub">子版块： 
                            <?php 
                            $queryc="select *from childModule where referid={$_GET['id']}";
                            $resultc=execute($link,$queryc);
                            while($datac=mysqli_fetch_assoc($resultc)){
                                $datac=dehtml($datac);
                                echo "<a href='childList.php?id={$datac['id']}'>{$datac['moduleName']}</a>&nbsp;&nbsp;"; 
                            }                          
                            ?>
                            </div>
                            <div class="page_index">
                                <input type="button" onclick="window.open('publish.php?fmid=<?php echo $_GET['id'];?>')" class="btn_link" value="发帖"/>
                               
                                <div class="pages fr">
                                    <?php $page_cur=3; $datas=pages($count_all,$page_cur);echo $datas['html'] ?>
                                </div>
                            </div>
                        </div>


                        <div class="middle_part">
                            <div class="comment">
                            <?php
                            if(!$count_all){
                                echo '<div class="group clear-float">暂无相关内容...</div>';
                            }else{
                                $queryp="select ct.id,ct.cmid,ct.title,ct.memberid,ct.time,ct.times,cm.moduleName from content ct,childModule cm where cm.referid={$_GET['id']} and cm.id=ct.cmid limit {$datas['limit']}";
                                $resultp=execute($link,$queryp);
                                while($datap=mysqli_fetch_assoc($resultp)){
                                    $datap=dehtml($datap);
                                    $datap['title']=tonl2br($datap['title']);
                                    $querym="select *from member where id={$datap['memberid']}";
                                    $resultm=execute($link,$querym);
                                    $datam=mysqli_fetch_assoc($resultm);
                                    $datam=dehtml($datam);
                                    $queryr="select *from reply where contentid={$datap['id']} order by id desc";
                                    $resultr=execute($link,$queryr);
                                    $count_rp=mysqli_num_rows($resultr);
                                    if($count_rp){
                                        $datar=mysqli_fetch_assoc($resultr); 
                                     }else{
                                         $datar['time']=$datap['time'];
                                     }
                                    echo '<div class="group clear-float"><div class="smallPic fl"> ';
                                    if(empty($datam['photo'])){
                                        echo " <a href='member.php'><img width='45' height='45' src='/Project_bbs/img/三儿.jpg'> </a></div>";
                                    }else{
                                        echo " <a href='member.php'><img width='45' height='45' src='{$datam['photo']}'> </a></div>";
                                    }
$html=<<<A
                                    <div class="text_mark fl">
                                        <div class="title_wrap"><a href="childList.php?id={$datap['cmid']}">[{$datap['moduleName']}]</a>&nbsp;&nbsp;<a class="bold" href="show.php?id={$datap['id']}">{$datap['title']}</a></div>
                                        <div class="remarks">楼主：<span>{$datam['name']}&nbsp;&nbsp;{$datap['time']}</span>&nbsp;&nbsp;最后回复：<span>{$datar['time']}</span></div>
                                    </div>
                                    <div class="count fr">
                                        <div class="part fr">回复<br/><span>{$count_rp}</span></div>
                                        <div class="part fr">浏览<br/><span>{$datap['times']}</span></div>           
                                    </div>
                                    </div>
A;
                                    echo $html;                            
                                }
                            }
                                
                            
                            ?>                
                            </div>




                            <div class="page_index">
                                    <input type="button" onclick="window.open('publish.php?fmid=<?php echo $_GET['id'];?>')"  class="btn_link" value="发帖"/>
                                    <div class="pages fr">
                                    <?php echo $datas['html'] ?>
                                    </div>
                            </div>
                    </div>
                    </div>
                </div>



                <div class="lfright fr">
                    <div class="content">
                        <h2 class="top">板块列表</h2>
                        <div class="inner">   
                            <?php
                            $queryf="select *from fatherModule order by sort desc";
                            $resultf=execute($link,$queryf);
                            while($dataf=mysqli_fetch_assoc($resultf)){
                                $dataf=dehtml($dataf);
                                echo "<ul>";
                                echo "<h2><a href='parentList.php?id={$dataf['id']}'>{$dataf['moduleName']}</a></h2>";
                                $queryc="select *from childModule where referid={$dataf['id']}";
                                $resultc=execute($link,$queryc);   
                                while($datac=mysqli_fetch_assoc($resultc)){
                                    $datac=dehtml($datac);
                                    echo " <li><a href='childList.php?id={$datac['id']}'>{$datac['moduleName']}</a></li>";
                                } 
                                echo "</ul>";
                            }
                            ?>  

                        </div>
                    </div>    
                </div>
            </div>
        </div>


<?php
include_once 'inc/footer.inc.php';
?>